<?php

include_once PATH_BASE.'model/factory/lineafactory.php';

class linea {
	
	public function __construct()
	{
	
	}
	
	//Action di default se nn viene definito il medoto da richiamare
	public function defAction()
	{
		return login();
	}
	
	
	//Action di rientro nella home dove rieseguire la login.
	public function login()
	{
		$username = $_POST['username'];
		$password = $_POST['pwd'];
		
			try
			{
				$uf = new utentewebfactory();
				$uf->bindUtenteWeb($username, $password);
				
				$utenteSess = $uf->getUser($username);
				
				$_SESSION[USER_SESSION] = serialize($utenteSess);
				return WELCOME_PAGE;
			}
			catch (Exception $e){
				
				template::getInstance()->addErrorMsg($e->getMessage());
				return LOGIN_PAGE;
			}
		
	}
	
	public function logout()
	{
		
		unset($_SESSION[USER_SESSION]);
		return LOGIN_PAGE;
	
	}
	
}
	
?>
